package com.cskaoyan.datasource.opensource;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * 创建日期: 2022/06/05 16:03
 *
 * @author ciggar
 */
public class C3p0Utils {

    static DataSource dataSource;

    static {

        // 采用 intergalactoApp 对应的配置
        // dataSource = new ComboPooledDataSource("intergalactoApp");
        // 使用默认的配置
        dataSource = new ComboPooledDataSource();

    }

    // 获取连接
    public static Connection getConnection(){

        Connection connection = null;
        try {
            connection = dataSource.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;

    }
}
